package com.xiao.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xiao.dao.CreateClassMapper;
import com.xiao.pojo.Classinfo;
import com.xiao.pojo.Subject;
import com.xiao.pojo.User;
import com.xiao.service.CreateClassService;
import com.xiao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CreateClassController {
    @Autowired
    private CreateClassService createClassService;
    @Autowired
    private UserService userService;
//    @Autowired
    private ObjectMapper objectMapper;



    @PostMapping("/createclass")
    public Object createclass(String classname, String gradename, String subjectname, String schoolname,long uid){
        boolean createclassone = createClassService.createclassone(classname, gradename, subjectname, schoolname, uid);
//        System.out.println(createclassone);
        if (createclassone){
            return classname;
        }else {
            return "0";
        }
    }

    @PostMapping("/findclass")
        public Object findclassinfo(long uid) {
        List<Classinfo> classinfos = userService.FindClassInfoByuid(uid);
System.out.println(classinfos);
        return classinfos;
        }

        //通讯录第一部分
    @PostMapping("/telinfo")
    public Object findourclassinfo(Classinfo classinfo, Subject subject,User user){
        List<User> findallinfo = createClassService.findallinfo(classinfo.getClassid());
        return  findallinfo;
    }
}
